package com.design.marketPrj.application.properties;


import java.util.List;
import java.util.Map;
import javax.servlet.Filter;
import org.apache.shiro.authc.Authenticator;
import org.apache.shiro.authz.permission.RolePermissionResolver;
import org.apache.shiro.realm.Realm;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;


@ConfigurationProperties(prefix = "framework.shiro")
@Component
public class ShiroProperties {
    public static final String PREFIX = "framework.shiro";
    private final ShiroProperties.RememberMe rememberMe = new ShiroProperties.RememberMe();
    private final ShiroProperties.SecurityManager securityManager = new ShiroProperties.SecurityManager();
    private final ShiroProperties.FilterFactoryBean filterFactoryBean = new ShiroProperties.FilterFactoryBean();
    private Boolean uniqueLogin = false;

    public ShiroProperties() {
    }

    public Boolean getUniqueLogin() {
        return this.uniqueLogin;
    }

    public void setUniqueLogin(Boolean uniqueLogin) {
        this.uniqueLogin = uniqueLogin;
    }

    public ShiroProperties.RememberMe getRememberMe() {
        return this.rememberMe;
    }

    public ShiroProperties.SecurityManager getSecurityManager() {
        return this.securityManager;
    }

    public ShiroProperties.FilterFactoryBean getFilterFactoryBean() {
        return this.filterFactoryBean;
    }

    public static class FilterFactoryBean  {
        private String loginUrl;
        private String successUrl;
        private Map<String, String> filterChainDefinitionMap;
        private Map<String, Class<? extends Filter>> filters;

        public FilterFactoryBean() {
        }

        public String getLoginUrl() {
            return this.loginUrl;
        }

        public void setLoginUrl(String loginUrl) {
            this.loginUrl = loginUrl;
        }

        public String getSuccessUrl() {
            return this.successUrl;
        }

        public void setSuccessUrl(String successUrl) {
            this.successUrl = successUrl;
        }

        public Map<String, String> getFilterChainDefinitionMap() {
            return this.filterChainDefinitionMap;
        }

        public void setFilterChainDefinitionMap(Map<String, String> filterChainDefinitionMap) {
            this.filterChainDefinitionMap = filterChainDefinitionMap;
        }


        public Map<String, Class<? extends Filter>> getFilters() {
            return this.filters;
        }

        public void setFilters(Map<String, Class<? extends Filter>> filters) {
            this.filters = filters;
        }
    }

    public static class SecurityManager {
        private Class<Authenticator> authenticator;
        private Class<Realm> authorizingRealm;
        private List<Class<Realm>> realms;
        private Class<RolePermissionResolver> rolePermissionResolver;

        public SecurityManager() {
        }

        public Class<Authenticator> getAuthenticator() {
            return this.authenticator;
        }

        public void setAuthenticator(Class<Authenticator> authenticator) {
            this.authenticator = authenticator;
        }

        public Class<Realm> getAuthorizingRealm() {
            return this.authorizingRealm;
        }

        public void setAuthorizingRealm(Class<Realm> authorizingRealm) {
            this.authorizingRealm = authorizingRealm;
        }

        public List<Class<Realm>> getRealms() {
            return this.realms;
        }

        public void setRealms(List<Class<Realm>> realms) {
            this.realms = realms;
        }

        public Class<RolePermissionResolver> getRolePermissionResolver() {
            return this.rolePermissionResolver;
        }

        public void setRolePermissionResolver(Class<RolePermissionResolver> rolePermissionResolver) {
            this.rolePermissionResolver = rolePermissionResolver;
        }
    }

    public static class RememberMe {
        private String cookieName = "_srm";
        private Integer cookieMaxAge = -1;

        public RememberMe() {
        }

        public String getCookieName() {
            return this.cookieName;
        }

        public void setCookieName(String cookieName) {
            this.cookieName = cookieName;
        }

        public Integer getCookieMaxAge() {
            return this.cookieMaxAge;
        }

        public void setCookieMaxAge(Integer cookieMaxAge) {
            this.cookieMaxAge = cookieMaxAge;
        }
    }
}
